package com.example.vo;

<<<<<<< Updated upstream
import org.apache.zookeeper.*;
import org.apache.zookeeper.data.Stat;

import java.util.concurrent.TimeUnit;

public class Java8Tester {

=======
import com.example.Enum.ResultEnum;
import com.example.demo.User;

import javax.xml.bind.SchemaOutputResolver;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
 * Description: 管理后台会员管理
 * Company    : 上海黄豆网络科技有限公司
 * @author     : liuhonger
 * Date       : 2018/4/7
 * Modify     : 修改日期          修改人员        修改说明          JIRA编号
 * v1.0.0        2018/4/7       liuhonger         新增              1001
 ********************************************************************/
public class Java8Tester {

    public static void main(String args[]){
        ExecutorService service = Executors.newFixedThreadPool(3);
        for(int i=0;i<2;i++){
            service.execute(new Runnable() {
                @Override
                public void run() {
                    if(Thread.currentThread().getName().equals("pool-1-thread-2")){
                        try {
                            TimeUnit.SECONDS.sleep(5);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    System.out.println("aa"+Thread.currentThread().getName());
                }
            });
        }

>>>>>>> Stashed changes



    public static void main(String args[])throws Exception{
        // 创建一个与服务器的连接
        ZooKeeper zk = new ZooKeeper("127.0.0.1:2181",3000,new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                // 事件状态为SyncConnected时，说明与服务端的连接已建立好
                System.out.println("事件状态:" + event.getState() +",事件类型:" +  event.getType() +",事件涉及路径:" + event.getPath());
                if (event.getState() == Event.KeeperState.SyncConnected){
                    if (event.getType() == Event.EventType.None && null == event.getPath()){
                        System.out.println("服务器 链接 成功");
                    }
                }else{
                    System.out.println("与服务器断开了链接");
                }
            }
        });
        // 创建一个目录节点
        zk.getChildren("/testRootPath", new Watcher() {
            @Override
            public void process(WatchedEvent watchedEvent) {
                try {
                    zk.getChildren("/testRootPath",this);
                } catch (Exception e) {
                }
                System.out.println("java8"+watchedEvent.getType());
            }
        });

        TimeUnit.SECONDS.sleep(100000);
    }






}
